package m202405.d13;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/13 15:45
 */
public class Q230 {
    public int kthSmallest(TreeNode root, int k) {
        travel(root, k);
        return cv;
    }

    int count = 0;
    int cv = 0;

    private void travel(TreeNode node, int k) {
        if (node == null) {
            return;
        }
        travel(node.left, k);
        if (count < k) {
            count++;
            cv = node.val;
        } else {
            return;
        }
        travel(node.right, k);
    }
}
